package com.base.java.disruptor;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class BeanManager<T> implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext application) throws BeansException {
        this.applicationContext = application;
    }

    public T getBean(Class<T> clazz){
        return applicationContext.getBean(clazz);
    }

    public Object getBean(String name){
        return applicationContext.getBean(name);
    }
}
